package com.augurit.gzcgwsp.rqqyjyxk.service.impl;

import java.util.HashMap;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;

import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkRqjszdjb;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkRqjszrypbqk;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkRqjszzysb;
import com.augurit.gzcgwsp.rqqyjyxk.dao.YwRqQyjyxkFinalRqjszdjbDao;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRqjszdjb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRqjszrypbqk;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRqjszzysb;
import com.augurit.gzcgwsp.rqqyjyxk.service.IYwRqQyjyxkFinalRqjszdjbService;
/**
 * 
 * <P>title:最终数据燃气接收站、储配站、汽车加气站登记表service实现类</p>																								
 * <P>Description：</p>
 * <p>Copyright: Copyright (c) 2011 augurit</p>
 * <p>Company: 广州奥格智能科技</p>
 * History：
 * @author:zhangjun
 * @date Oct 15, 2011
 * @version 1.0
 */
@Service("rqjszdjbService")
@Transactional
public class YwRqQyjyxkFinalRqjszdjbServiceImpl   implements IYwRqQyjyxkFinalRqjszdjbService{
	@Autowired
	private YwRqQyjyxkFinalRqjszdjbDao rqjszdjbDao;

    public List<YwRqQyjyxkFinalRqjszdjb> getInfosByQyid(Long qyid) {
       String  sql=" from "+ YwRqQyjyxkFinalRqjszdjb.class.getName()+" where qyid='"+qyid+"'";
        return rqjszdjbDao.find(sql);
    }

    public Long save(YwRqQyjyxkFinalRqjszdjb finalentity) {
        return this.rqjszdjbDao.saveEntity(finalentity);
    }

    public YwRqQyjyxkFinalRqjszdjb getZdInfo(String zdid) {
        YwRqQyjyxkFinalRqjszdjb entity=null;
       if(StringUtils.isNotBlank(zdid))
          entity=rqjszdjbDao.getEntity(Long.valueOf(zdid));
         return entity;
       
    }

    public List<YwRqQyjyxkFinalRqjszrypbqk> getDatasByzdid(Long id) {
        String hql=" from "+YwRqQyjyxkFinalRqjszrypbqk.class.getName()+" where gyzid='"+id+"'";
        return this.rqjszdjbDao.find(hql);
    }

    public List<YwRqQyjyxkFinalRqjszzysb> getzysbDatas(Long id) {
        String hql=" from "+YwRqQyjyxkFinalRqjszzysb.class.getName()+" where gyzid='"+id+"'";
        return this.rqjszdjbDao.find(hql);
    }

    /*
     * (non-Javadoc)
     * @see com.augurit.gzcgwsp.rqqyjyxk.service.IYwRqQyjyxkFinalRqjszdjbService#getPage(java.lang.String, org.springside.modules.orm.Page, java.lang.Long, java.lang.String)
     */
	public Page getPage(String acceptNo, Page page, Long qyid, String type) {
		 String  hql=" from "+ YwRqQyjyxkRqjszdjb.class.getName()+" where acceptNo='"+acceptNo+"'";
		    if("2".equals(type)){
		    	hql=" from "+ YwRqQyjyxkFinalRqjszdjb.class.getName()+" where qyid='"+qyid+"'";
		    	
		    }
			 return rqjszdjbDao.findPage(page, hql, new HashMap());
	}

	/*
	 * (non-Javadoc)
	 * @see com.augurit.gzcgwsp.rqqyjyxk.service.IYwRqQyjyxkFinalRqjszdjbService#getPage(java.lang.String, java.lang.Long)
	 */
	public Page getPage(Page page,String zdid, Long qyid,String type) {
		 String hql=" from "+YwRqQyjyxkRqjszrypbqk.class.getName()+" where gyzdjid="+zdid;
		 if("sb".equals(type)){
			 hql=" from "+YwRqQyjyxkRqjszzysb.class.getName()+" where gyzid="+zdid;
		 }else if("oldperson".equals(type)){
			 hql=" from "+YwRqQyjyxkFinalRqjszrypbqk.class.getName()+" where gyzid="+zdid;
		 }else if("oldsb".equals(type)){
			 hql=" from "+YwRqQyjyxkFinalRqjszzysb.class.getName()+" where gyzid="+zdid;
		 }
			 return rqjszdjbDao.findPage(page, hql, new HashMap());
	}
	
	

}
